package com.mapper;

import com.bean.ClazzBean;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ClazzMapperByAnnotation {

    @Select("select * from t_clazz")
    public List<ClazzBean> findAllClazz();

    @Select("select * from t_clazz where id=#{id}")
    public ClazzBean findClazzByid(Integer id);

    @Insert("insert into t_clazz (cname) values (#{cname})")
    public int addClazz(ClazzBean clazzBean);

    @Update("update t_clazz set cname=#{cname} where id=#{id}")
    public int modifyClazzBean(ClazzBean clazzBean);

    @Delete("delete from t_clazz where id=#{id}")
    public int delClazz(int id);

    //1:m 查找一个班下的学生信息

    @Select("select * from t_clazz where id=#{id}")
    @Results({
            @Result(id = true,column = "id",property = "id"),
            @Result(column = "cname",property = "cname"),
            @Result(column = "id",property = "studentBeans",
                    many = @Many(select = "com.mapper.StudentMapperByAnnotation.findStuByClassid")),
    })
    public ClazzBean findStuForClazzById(Integer id);

    @Select("select * from t_clazz where id=#{classid}")
    public ClazzBean findClassByClassid(Integer classid);





}
